<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>订单管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="../../css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">

        <fieldset class="table-search-fieldset">
            <legend>搜索信息</legend>
            <div style="margin: 10px 10px 10px 10px">
                <div class="layui-form layui-form-pane">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">订单编号</label>
                            <div class="layui-input-inline">
                                <input id="iid" type="text" name="iid" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">发起人姓名</label>
                            <div class="layui-input-inline">
                                <input id="ename" type="text" name="ename" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">供应商公司</label>
                            <div class="layui-input-inline">
                                <input id="firm" type="text" name="firm" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary"  lay-submit lay-filter="data-search-btn"><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>
                </div>
            </div>
        </fieldset>


        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter"></table>

        <%--        损坏--%>
        <script type="text/html" id="factTpl">
            {{#  if(d.num>d.fact){ }}
            <span style="color: #FF8C00;">{{d.fact+d.mbig}}</span>
            {{#  } else if(d.num < d.fact){ }}
            <span style="color: #CD853F;">{{d.fact+d.mbig}}</span>
            {{#  } else { }}
            {{d.fact+d.mbig}}
            {{#  } }}
        </script>

        <%--        审批状态--%>
        <script type="text/html" id="examineTpl">
            {{#  if(d.manager === 0){ }}
            <span style="color: #9ACD32;">经理未审批</span>
            {{#  } else if(d.manager === 1&&d.payment===0){ }}
            <span style="color: #ADFF2F;">店长未审批</span>
            {{#  } else if(d.manager === 1&&d.payment === 1){ }}
            <span style="color: #7CFC00;">同意购买</span>
            {{#  } else if(d.manager === 1&&d.payment === 2){ }}
            <span style="color: #00FF00;">已付款</span>
            {{#  } }}
        </script>


        <%--        保管员接收状态--%>
        <script type="text/html" id="receiveTpl">
            {{#  if(d.receive === 1){ }}
            <span style="color: #02DF82;">核对完成</span>
            {{#  } else { }}
            未接收
            {{#  } }}
        </script>

    </div>
</div>
<script src="../../lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
<script src="../../../../jquery-3.3.1.js" charset="UTF-8"></script>
<script>
    layui.use(['form', 'table'], function () {
        var $ = layui.jquery,
            form = layui.form,
            table = layui.table,
            laydate = layui.laydate,
            util = layui.util;

        table.render({
            elem: '#currentTableId',
            url: '/indent/list',
            toolbar: '#toolbarDemo',
            escape: true,
            defaultToolbar: ['filter', 'exports', 'print', {
                title: '提示',
                layEvent: 'LAYTABLE_TIPS',
                icon: 'layui-icon-tips'
            }],
            cols: [[
                {width:20},
                {field: 'iid', Width:100, title: '订单编号', sort: true},
                {field: 'ename', minWidth:1, title: '发起人'},
                {field: 'cname', minWidth:1, title: '商品名称'},
                {field: 'tname',minWidth:1, title: '商品类型'},
                {field: 'price', minWidth:1, title: '单价',templet:function (d) {
                        return d.price+'元/'+d.mbig
                    }},
                {field: 'scale', minwidth: 90, title: '规格',templet:function (d) {
                        return d.scale+d.mlittle+"/"+d.mbig
                    }},
                {field: 'firm',minWidth:1, title: '供应商公司'},
                {field: 'num', minWidth:1, title: '采购数量', sort: true,templet:function (d) {
                        return d.num+d.mbig
                    }},
                {field: 'fact', minWidth:1, title: '实收数量', sort: true,templet:'#factTpl'},
                {field: 'expense',minWidth:1, title: '所需金额', sort: true,templet:function (d) {
                        return d.price*d.num+'元'
                    }},
                {field: 'manager', Width:250, title: '审批状态',templet: '#examineTpl'},
                {field: 'deliveryTime',minWidth:1, title: '交期'},
                {field: 'receive', minWidth:1, title: '接收状态',templet:'#receiveTpl'},
                {field: 'endTime', minWidth:1, title: '入库时间',sort:true}
            ]], page:true,
            limits: [5,10, 15]
            , limit: 10
            , parseData: function (res) { //将原始数据解析成 table 组件所规定的数据，res为从url中get到的数据
                var result;
                if (this.page.curr) {
                    result = res.data.slice(this.limit * (this.page.curr - 1), this.limit * this.page.curr);
                }
                else {
                    result = res.data.slice(0, this.limit);
                }
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": result //解析数据列表
                };
            }
        });
        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    iid:$("#iid").val(),
                    ename:$("#ename").val(),
                    firm:$("#firm").val(),
                }
            }, 'data');
            return false;
        });



    });
</script>

</body>
</html>